package com.llkj.qingnianguoxue.adapter;

import android.view.View;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.llkj.qingnianguoxue.R;
import com.llkj.qingnianguoxue.bean.HotRankingBean;
import com.llkj.qingnianguoxue.util.DisplayUtil;
import com.llkj.qingnianguoxue.util.ImageLoadingUtil;
import com.llkj.qingnianguoxue.util.StringUtils;

import java.util.List;

/**
 * 购物车订单适配器
 */
public class PayCartOrderAdapter extends BaseQuickAdapter<HotRankingBean.RankingBean, BaseViewHolder> {

    public PayCartOrderAdapter(int layoutResId, List<HotRankingBean.RankingBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, HotRankingBean.RankingBean item) {
        ImageView ivPic = baseViewHolder.getView(R.id.pic);
        ImageLoadingUtil.loadImgGlideRoundCenterCrop(ivPic, item.getImg());
        FrameLayout.LayoutParams picParam = (FrameLayout.LayoutParams) ivPic.getLayoutParams();
        picParam.height = DisplayUtil.dip2px(mContext,85);

        baseViewHolder.setText(R.id.tv_title, item.getTitle());
        baseViewHolder.setText(R.id.tv_introduction,item.getAbstractX());
        TextView tvTag = baseViewHolder.getView(R.id.tvTag);
        if(!StringUtils.isEmpty(item.getClassify())){
            tvTag.setVisibility(View.VISIBLE);
            tvTag.setText(item.getClassify());
        }else{
            tvTag.setVisibility(View.INVISIBLE);
        }

        baseViewHolder.addOnClickListener(R.id.iv_check);

        ImageView ivPlay = baseViewHolder.getView(R.id.iv_video_play);
        if(2==item.getType()){// 类型 1 视频2 图书
            picParam.width = picParam.height*13/14;
            ivPlay.setVisibility(View.INVISIBLE);
        }else{
            picParam.width = picParam.height*16/9;
            ivPlay.setVisibility(View.VISIBLE);
        }
    }

}
